const SIZE = {
    B: 1,
    KB: 2 << (10 - 1),
    MB: 2 << (20 - 1),
    GB: 2 << (30 - 1),
}

export default function sizeFormat(size) {
    if (size >= SIZE.B && size < SIZE.KB) return size + 'B'
    else if (size >= SIZE.KB && size < SIZE.MB) return (size / SIZE.KB).toFixed(1) + 'KB'
    else if (size >= SIZE.MB && size < SIZE.GB) return (size / SIZE.MB).toFixed(1) + 'MB'
    else return (size / SIZE.GB).toFixed(1) + 'GB'
}